﻿
Imports remotecall

Public Class rc_pac_detector
    Inherits rcDetector(Of rc_pac_serve, envelope, envelope)

    Public Class naming
        Public Const ijob As String = "ijob"
    End Class

    Protected Overrides Function create_output() As envelope
        Return New envelope()
    End Function

    Protected Overrides Function create_server(ByVal port As Int32, ByVal connectionCount As Int64) As rc_pac_serve
        Return New rc_pac_serve(port)
    End Function

    Protected Overrides Sub inject_output_ijob(ByVal i As envelope, ByVal job As ijob)
        assert(i.add(naming.ijob, job))
    End Sub

    Protected Overrides Function parse_input_ijob(ByVal i As envelope, ByRef o As ijob) As Boolean
        Return i.get(naming.ijob, o)
    End Function

    Protected Overrides Function parse_input_valid(ByVal i As envelope) As Boolean
        Return Not i Is Nothing
    End Function

    Protected Overrides Sub register(ByVal server As rc_pac_serve,
                                     ByVal name As String,
                                     ByVal d As _do(Of envelope, pointer(Of envelope), eventComb))
        assert(server.register(name, d))
    End Sub

    Protected Overrides Function start_server(ByVal server As rc_pac_serve,
                                              ByVal port As Int32,
                                              ByVal connectionCount As Int64) As Boolean
        server.maxConnectionCount() = connectionCount
        Return True
    End Function

    Protected Overrides Sub stop_server(ByVal server As rc_pac_serve)
    End Sub
End Class
